/** @file
 * @brief Concrete data types.
 *
 * On the one hand, having these all in the same file isn't
 * good modularity. On the other hand, I don't want to write
 * loads of setters and getters.
 */
/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
 *
 *	Permission is hereby given to reproduce or modify this
 *	software freely, provided that this notice be retained,
 *	and that no use be made of the software for commercial
 *	purposes without the express written permission of the
 *	author.
 */

#ifndef _TYPES_H_
#define _TYPES_H_

#include <list>

/** @todo Remove this */
#define	us		unsigned

/** Max no. of header levels */
#define	NLEVELS	20

/** Type for header levels member of label struct */
typedef int levels[NLEVELS];

/** Header format */
typedef char *format;

typedef struct Type Type;		/**< Type type */
typedef struct Label Label;		/**< Label type */
typedef struct Keyword Keyword;		/**< Keyword type */

/** Label type */
struct Type {
	char   *t_name;			/**< name */
	levels	t_levels;		/**< current header levels */
	format	t_format;		/**< format */
	std::list<Label> labelhead;	/**< list of labels of this type */
};

/** Label definition */
struct Label {
	char   *l_name;			/**< Name */
	Type   *l_type;			/**< Back-reference to label type */
	char   *l_file;			/**< File where defined */
	long	l_line;			/**< line where defined */
	levels	l_levels;		/**< Counter for label no. at different levels */
	int	l_bottom;		/**< Last significant level */
	unsigned char padding[4];
};

/** Action routine for keyword processing */
typedef int (*func) ();

/** Command keyword, to come after ".L=" at the start of an input line */
struct Keyword {
	char   *k_name;			/**< How is the keyword spelt */
	func	k_action;		/**< Function pointer for action to take */
	us int	k_minargs;		/**< Min no. of args for k_action */
	us int	k_maxargs;		/**< Max no. of args for k_action */
};

#endif
